#include <cstdio>
#include <cstring>
#define MAXN 501
#define _clr(x) memset(x,0xff,sizeof(int)*MAXN)
struct edge_t{
    int from,to;
    edge_t* next;
};
int hungary(int m,int n,edge_t* list[],int* match1,int* match2){
    int s[MAXN],t[MAXN],p,q,ret=0,i,j,k;edge_t* e;
    for (_clr(match1),_clr(match2),i=0;i<m;ret+=(match1[i++]>=0))
        for (_clr(t),s[p=q=0]=i;p<=q&&match1[i]<0;p++)
            for (e=list[k=s[p]];e&&match1[i]<0;e=e->next)
                if (t[j=e->to]<0){
                    s[++q]=match2[j],t[j]=k;
                    if (s[q]<0)
                        for (p=j;p>=0;j=p)
                            match2[j]=k=t[j],p=match1[k],match1[k]=j;
                }
    return ret;
}

edge_t *list[ 501 ];
int num[ 501 ], n, m, p, nn, nm;
char s[ 501 ][ 2 ][ 20 ];

void init( )
{
    int i, j;
    edge_t *q;
    nn = nm = 0;
    for ( i = 0; i < p; i++ )
    {
        scanf("%s%s", s[ i ][ 0 ], s[ i ][ 1 ]);
        if ( s[ i ][ 0 ][ 0 ] == 'C' )
            num[ i ] = nn++;
        else
            num[ i ] = nm++;
    }
    memset( list, NULL, sizeof( list ) );
    for ( i = 0; i < p; i++ )
        if ( s[ i ][ 0 ][ 0 ] == 'C' )
            for ( j = 0; j < p; j++ )
                if ( strcmp( s[ i ][ 0 ], s[ j ][ 1 ] ) == 0 || strcmp( s[ i ][ 1 ], s[ j ][ 0 ] ) == 0 )
                {
                    q = new edge_t;
                    q->from = num[ i ]; q->to = num[ j ];
                    if ( !list[ num[ i ] ] )
                    {
                        q->next = NULL;
                        list[ num[ i ] ] = q;
                    }
                    else
                    {
                        q->next = list[ num[ i ] ]->next;
                        list[ num[ i ] ]->next = q;
                    }
                }
}

int match1[ MAXN ], match2[ MAXN ];

int main( )
{
    while ( scanf("%d%d%d", &n, &m, &p) != EOF )
    {
        init( );
        printf("%d\n", p - hungary( nn, nm, list, match1, match2 ));
    }
    return 0;
}
